<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :md="6" :sm="8">
            <a-form-item label="字典名称">
              <a-input placeholder="请输入字典名称" v-model="queryParam.name"></a-input>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="8">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>


    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a
        style="font-weight: 600">{{
        selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        @change="handleTableChange">

        <template slot="statusslot" slot-scope="text, record, index">
          <a-tag color="pink" v-if="record.systemStatus">是</a-tag>
          <a-tag color="gray" v-if="!record.systemStatus">否</a-tag>
        </template>

        <span slot="action" slot-scope="text, record">
            <a v-if="!record.systemStatus" @click="dictDelete(record.id)">删除</a>
        </span>

      </a-table>
    </div>
    <!-- table区域-end -->
  </a-card>
</template>

<script>
  import {TableListMixin} from '@/mixins/TableListMixin'
  import '@/assets/less/common.css';

  export default {
    name: "dictList",
    mixins: [TableListMixin],
    data() {
      return {
        queryParam: {},
        // 表头
        columns: [
          {
            title: '字典编码',
            align: "center",
            dataIndex: 'code'
          },
          {
            title: '字典名称',
            align: "center",
            dataIndex: 'name'
          },
          {
            title: '字典类型编码',
            align: "center",
            width: 150,
            dataIndex: 'typeCode',
          },
          {
            title: '字典类型名称',
            align: "center",
            width: 150,
            dataIndex: 'typeName',
          },
          {
            title: '系统字典',
            align: "center",
            dataIndex: 'systemStatus',
            scopedSlots: {customRender: "statusslot"}
          },
          {
            title: '排序',
            align: "center",
            dataIndex: 'sort',
          },
          {
            title: '创建时间',
            align: "center",
            dataIndex: 'createTime'
          },
          {
            title: '创建人',
            align: "center",
            dataIndex: 'createBy'
          },
          {
            title: '操作',
            dataIndex: 'action',
            align: "center",
            scopedSlots: {customRender: 'action'},
          }
        ],
        url: {
          list: "/baseDictionary/getPageList",
          delete: "/baseDictionary/delete"
        }
      }
    },
    methods: {
      dictDelete(id) {
        var that = this;
        that.$confirm({
          title: "确认删除",
          content: "是否删除选中项?",
          onOk: function () {
            that.handleDelete(id)
          }
        });
      },
    }
  }
</script>
